package com.lihua.newideas.mapper;

import com.lihua.newideas.pojo.Article;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ArticleMapper {
//    添加文章
    void addArticle(Article article);
//    查找所有文章
    List<Article> queryArticleAll();

    /*
    * 根据id查询文章
    * */
    @Select("select * from article where id = #{id}")
    Article queryArticleById(@Param("id") Long id);

    /*根据id修改文章 ,直接根据id插入
    * */
    void updateArticleById(Article article);

    /*
    * 根据id删除文章
    * */
    @Delete("delete from article where id = #{id}")
    void deleteArticleById( @Param("id") long id);

    /*
    * 根据articleStatus 文章状态o已发布1草稿2回牧站
    * 查询文章
    * */
    @Select("select * from article where article_status = #{articleStatus}")
    List<Article> queryArticleByArticleStatus( @Param("articleStatus")int articleStatus);

    /*
    * 根据标题搜索文章
    * */
    List<Article> queryArticleByArticleTitle(String articleTitle);

    /*
    * 统计文章数量
    * */
    @Select("select count(*) from article where article_type = #{articleType}")
    int queryArticleNumByArticleStatus(@Param("articleType") long articleType);
}
